#include "StdAfx.h"
#include "dgraphicsview.h"
#include "ddocument.h"
#include "dvariableentity.h"
#include "dmethodentity.h"
#include "denumentity.h"
#include "dclassentity.h"

DGraphicsView::DGraphicsView(QWidget *parent)
	: QWidget(parent)
{

}

DGraphicsView::~DGraphicsView()
{

}

void DGraphicsView::setDocument(DDocument* pDoc)
{
	m_pDoc = pDoc;
}

void DGraphicsView::paintEvent(QPaintEvent*)
{
	QPainter painter(this);
	painter.fillRect(rect(), Qt::white);

	if(m_pDoc->classes().size())
	{
		DClassEntity* pRoot = m_pDoc->classes().first();

		drawClass(painter, pRoot);
	}
}

void DGraphicsView::drawClass(QPainter& painter, DClassEntity* pClass)
{
	int nMaxLevel = 0;//DClassEntity::maxLevel();

	QRect gwRect = rect();

	int height = gwRect.height()/2;
	
	if(nMaxLevel > 0)
	{
		height = gwRect.height()/(nMaxLevel*2);
	}

	int width = 100;
	int posY = height*pClass->level();
	int posX = gwRect.width()/2 - width/2;

	if(DClassEntity* pParent = pClass->baseClass())
	{
		
	}
	else
	{	
		//painter.drawRect(posX, posY, width, height);
	}	
}

void DGraphicsView::drawClassGeometry()
{

}